package main

import (
	_ "bugManagementPlatform/dataInit"
	"bugManagementPlatform/middleware"
	"bugManagementPlatform/router"
	"bugManagementPlatform/utils"
	"bugManagementPlatform/variable"
	"github.com/savsgio/atreugo/v11"
)

func main()  {

	if variable.Db != nil{
		db, _ := variable.Db.DB()
		defer db.Close()
	}

	config := atreugo.Config{
		Addr: "0.0.0.0:3400",
	}
	variable.Server = atreugo.New(config)

	//variable.Server.UseAfter(middleware.JWTAuthMiddleware).UseBefore(middleware.Cors()) // 错误
	variable.Server.UseBefore(middleware.Cors()).UseBefore(middleware.JWTAuthMiddleware)
	//variable.Server.UseBefore(middleware.Cors()).UseAfter(middleware.JWTAuthMiddleware) // 错误
	//variable.Server.UseAfter(middleware.Cors()).UseAfter(middleware.JWTAuthMiddleware) // 错误

	// 错误 请求之前 请求之后
	//variable.Server.UseBefore(middleware.JWTAuthMiddleware).UseAfter(middleware.Cors())

	variable.W = utils.NewWorkerNovel()

	router.NewBugManagementRoute().RouteInit()

	if err := variable.Server.ListenAndServe(); err != nil {
		panic(err)
	}
}




